// 状态库
import { defineStore } from "pinia";
import { is_object, str_utils } from '../tool/common'
const saveForm = defineStore("_form", {
    state: () => ({
        data: null,
    }),
    getters: (state) => state.data,
    actions: {
        save(val) {
            if (is_object(val)) {
                this.data = val;
            } else {
                throw new TypeError("数据不是JSON表单格式");
            }
        },
        clear() {
            this.data = null;
        }
    }
});

const tabSelection = defineStore("_tab", {
    state: () => ({
        param: null,
    }),
    getters: (state) => state.data,
    actions: {
        save(val) {
            if (str_utils.not_empty(val)) {
                this.param = val;
            } else {
                throw new TypeError("数据类型错误");
            }
        },
        clear() {
            this.param = null;
        }
    }
})
export {
    saveForm,
    tabSelection
}